home *** CD-ROM | disk | FTP | other *** search
- PROGRAM Printpascal ;
- { Program to make a printout of a pascal listing }
- { puts header with program name & date }
- { puts a footer with page number }
- { use item selector box to get the file }
- { WILLIAM R. GOOD JULY 1986 }
-
- CONST
- {$I GEMCONST.PAS}
-
- TYPE
- {$I gemtype.pas}
- prtype = FILE OF TEXT ;
- tftype = FILE OF TEXT ;
-
- VAR
- pathname, filename : Path_Name ;
- selection : boolean ;
- textfile : tftype ;
- prtfile : prtype ;
-
- {$I gemsubs} { and that ".PAS" is default }
-
- { the next two functions are added to personal pascal }
-
- FUNCTION t_getdate : integer ;
- GEMDOS( $2a ) ;
-
- FUNCTION t_gettime : integer ;
- GEMDOS( $2c ) ;
-
- PROCEDURE info ;
- { prints the copyright notice on the screen }
- { in a alert box. OSS wants this }
- VAR
- button : integer ;
- alerttext : string[255] ;
- part1, part2, part3, part4, part5 : string ;
- BEGIN
- part1 := '[3][Printpascal by William R. Good|' ;
- part2 := 'Portions of this product are|' ;
- part3 := 'Copyright (c) 1986 OSS and CCD|' ;
- part4 := 'Used by Permission of OSS.|' ;
- part5 := 'Written on 06-29-86 ][ OK ]' ;
- alerttext := Concat ( part1, part2, part3, part4, part5 ) ;
- button := Do_Alert(alerttext,1) ;
- END ; {info}
-
- PROCEDURE Inttostr (int : integer; VAR inttext : string);
- {Generic procedure to convert integers to strings, packs front with zeros.}
- VAR
- place,digit : integer;
- tempstr : string ;
- BEGIN
- tempstr := '' ;
- FOR place:=1 DOWNTO 0 DO
- BEGIN
- digit:=int DIV Round(PwrOfTen(place));
- tempstr := concat (tempstr, chr(digit+ord('0'))) ;
- int:=int MOD Round(PwrOfTen(place));
- END;
- inttext := tempstr ;
- END; {Inttostr}
-
- PROCEDURE getdate (var datestr : string ) ;
- { procedure to return the date in a string }
- VAR
- dateint,tempint,
- yearint, monthint, dayint : integer ;
- yearstr, monthstr, daystr : string ;
- BEGIN
- dateint := t_getdate ;
- yearint := dateint div 512 ;
- yearint := yearint + 80 ;
- tempint := dateint mod 512 ;
- monthint := tempint div 32 ;
- dayint := tempint mod 32 ;
- inttostr( yearint, yearstr ) ;
- inttostr( monthint, monthstr ) ;
- inttostr( dayint, daystr ) ;
- datestr := concat( monthstr, '/', daystr, '/', yearstr ) ;
- END ; { getdate }
-
- PROCEDURE gettime (var timestr : string ) ;
- { procedure to return the time in a string }
- VAR
- timeint,tempint,
- hourint, minint, secint : integer ;
- hourstr, minstr, secstr : string ;
- BEGIN
- timeint := t_gettime ;
- hourint := timeint div 2048 ;
- tempint := timeint mod 2058 ;
- minint := tempint div 32 ;
- secint := tempint mod 32 ;
- secint := secint * 2 ;
- inttostr( hourint, hourstr ) ;
- inttostr( minint, minstr ) ;
- inttostr( secint, secstr ) ;
- timestr := concat( hourstr, ':', minstr, ':', secstr ) ;
- END ; { gettime }
-
- PROCEDURE printhead ;
- { prints header with full pathname }
- { and date }
- var
- times1, times2 : integer ;
- headline, time, date : string ;
- begin
- rewrite( prtfile, 'LST:' ) ;
- for times1 := 1 to 2 do
- begin
- writeln( prtfile ) ; { space down some lines }
- end ;
- getdate ( date ) ;
- gettime ( time ) ;
- headline := concat(filename, ' ', time,' ', date ) ;
- writeln( prtfile, headline ) ; { need to add filename here }
- for times2 := 1 to 2 do
- begin
- writeln( prtfile ) ;
- end ;
- end ; { printhead }
-
- PROCEDURE printfoot( pagenum : integer ) ;
- { prints footer with page number }
- { at the bottom of page in center }
- var
- line, textline : string ;
- pagestr : string ;
- tempnum, index, times1, times2 : integer ;
- begin
- rewrite( prtfile, 'LST:' ) ;
- for times1 := 1 to 2 do
- begin
- writeln( prtfile ) ;
- end ;
- inttostr( pagenum, pagestr ) ;
- textline := ' PAGE NUMBER : ' ;
- textline := concat( textline, pagestr ) ;
- writeln( prtfile, textline ) ;
- for times2 := 1 to 2 do
- begin
- writeln( prtfile ) ;
- end
- end ; { printfoot}
-
- PROCEDURE printfile ;
- { prints the pascal file to the printer }
- { prints header and footer with page number }
- VAR
- textfile : tftype ;
- prtfile : prtype ;
- number, tempnum, strline : string ;
- check, linecount, pagenumber : integer ;
- BEGIN
- pagenumber := 0 ;
- linecount := 1 ;
- rewrite( prtfile, 'LST:' ) ;
- pathname := 'A:\*.PAS' ;
- selection := true ;
- selection := Get_In_File( pathname, filename ) ;
- if selection then
- begin
- set_mouse(m_bee) ;
- printhead ;
- reset( textfile, filename ) ;
- while (not eof( textfile )) do
- begin
- readln ( textfile, strline ) ;
- writeln ( prtfile, strline ) ;
- linecount := linecount + 1 ;
- if linecount = 57 then
- begin
- pagenumber := pagenumber + 1 ;
- printfoot ( pagenumber ) ;
- printhead ;
- linecount := 1 ;
- end ;
- end ;
- if linecount < 57 then
- begin
- repeat
- writeln ( prtfile ) ;
- linecount := linecount + 1 ;
- until linecount = 57 ;
- pagenumber := pagenumber + 1 ;
- printfoot ( pagenumber ) ;
- end ;
- set_mouse(m_arrow) ;
- end ;
- end ; { end printfile }
-
- BEGIN {Main Module}
- IF Init_Gem >= 0 THEN
- BEGIN
- info ;
- printfile ;
- close( textfile ) ;
- close( prtfile ) ;
- Exit_Gem ;
- END ;
- END. {Printpascal}
-
-
-
- əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə